package model;


import java.util.ArrayList;
import java.util.List;

public class BookDB {
    private static List<Book> books = new ArrayList<>();

    static {
        // 初始化一些图书数据
        books.add(new Book("1", "Java从入门到精通", 59.9));
        books.add(new Book("2", "Python编程实战", 49.9));
        books.add(new Book("3", "Web开发入门指南", 39.9));
    }

    public static List<Book> getAllBooks() {
        return books;
    }

    public static Book getBookById(String id) {
        for (Book book : books) {
            if (book.getId().equals(id)) {
                return book;
            }
        }
        return null;
    }
}